package io;

import java.io.*;

/**
 * @author haomin
 * @date 2022/06/10 15:53
 **/
public class ReaderOrWrite {
    public static void main(String[] args) throws IOException {
        File file = new File("C:\\Users\\86187\\IdeaProjects\\javaEE_learn\\src\\io\\aaa.txt");
        OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file),"gbk");
        //FileWriter writer = new FileWriter(file);
        String str = "中国";
        writer.write(str);
        writer.close();

        InputStreamReader reader = new InputStreamReader(new FileInputStream(file),"gbk");
        int c;
        while ((c = reader.read()) != -1){
            System.out.println((char)c);
        }
        reader.close();

//        String encoding = System.getProperty("file.encoding");
//        System.out.println(encoding);
    }
}